import request, { reqJson } from './requestWithToken';
import { stringify } from 'qs';
import domain from '@/utils/domain';

export function loginSuccessPage(param) {
  const url = `${domain.user}/usercenter/admin/log/login/page`;
  return reqJson.get(url, param);
}

export function loginSuccessExportData(param) {
  let url = `${domain.user}/usercenter/admin/log/login/export`;
  if (param) url += `?${stringify(param)}`;
  return request(url, {
    method: 'GET',
  }).then(response => response.blob());
}

export function loginFailPage(query) {
  const url = `${domain.user}/usercenter/admin/log/login/failure/page`;
  return reqJson.get(url, query);
}

export function loginFailExportData(param) {
  let url = `${domain.user}/usercenter/admin/log/login/failure/export`;
  if (param) url += `?${stringify(param)}`;
  return request(url, {
    method: 'GET',
  }).then(response => response.blob());
}
